﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using TSqlServer;

public partial class user_user_chg_email : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
        }
        else
        {
            TUser.CheckUser(this);
            btnSave.Attributes.Add("OnClick", "javascript:return chk();");
        }
    }
    protected void btnBack_Click(object sender, EventArgs e)
    {
        this.Response.Redirect("user_myself.aspx");
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string sid = this.Session["ecrm_uid"].ToString();
        string semail = this.Session["ecrm_email"].ToString();

        if (oldemail.Text == semail)
        {
            if (TUser.CheckLogin(oldemail.Text, password.Text))
            {
                TUser oUser = new TUser(sid);
                oUser.EMail = newemail.Text;
                oUser.Update_email();

                //新建对应的文件夹，用来保存fckediter上传的文件------------------
                string rootdir = "d:\\www\\easycrm\\uploadfiles\\";
                string newfolder = rootdir + oUser.EMail;
                Directory.CreateDirectory(newfolder);
                //---------------------------------------------------------------
                
                this.Response.Redirect("user_myself.aspx");
            }
            else
            {
                msg.Text = "密码不正确！";
            }
        }
        else
        {
            msg.Text = "现在使用的邮箱与输入的不符！";
        }
    }
}
